//2009/10/23 18:46:06
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class BlackAndRed
{
public:
    int cut(string deck)
    {
		int ret = 0;
		int best = 0;
		int total = 0;
		for(int i=0; i<deck.size(); i++)
		{
			total += (deck[i]=='B' ? 1 : -1);
			if(total < best)
			{
				best = total;
				ret = i + 1;
			}
		}
		return ret;
    }
};
